package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.system.domain.*;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.service.IScStudentCourseService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 报名系统Controller
 * 
 * @author ZHANGQIBO
 * @date 2023-12-29
 */
@RestController
@RequestMapping("/system/scStudentCourse")
public class ScStudentCourseController extends BaseController
{
    @Autowired
    private IScStudentCourseService scStudentCourseService;

    /**
     * 查询报名系统列表
     */
    @PreAuthorize("@ss.hasPermi('system:scStudentCourse:list')")
    @GetMapping("/list")
    public TableDataInfo list(ScStudentCourse scStudentCourse)
    {
        startPage();
        List<ScStudentCourse> list = scStudentCourseService.selectScStudentCourseList(scStudentCourse);
        return getDataTable(list);
    }

    /**
     * 查询报名系统列表
     */
//    @PreAuthorize("@ss.hasPermi('system:scStudentCourse:list')")
    @GetMapping("/ScStudentlistAPP")
    public AjaxResult ScStudentlistAPP(Long claid)
    {
        List<StudentApp> list = scStudentCourseService.selectStudentAppList(claid);
        return AjaxResult.success(list);
    }

    /**
     * 导出报名系统列表
     */
    @PreAuthorize("@ss.hasPermi('system:scStudentCourse:export')")
    @Log(title = "报名系统", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ScStudentCourse scStudentCourse)
    {
        List<ScStudentCourse> list = scStudentCourseService.selectScStudentCourseList(scStudentCourse);
        ExcelUtil<ScStudentCourse> util = new ExcelUtil<ScStudentCourse>(ScStudentCourse.class);
        util.exportExcel(response, list, "报名系统数据");
    }

    /**
     * 获取报名系统详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:scStudentCourse:query')")
    @GetMapping(value = "/{studentCourseId}")
    public AjaxResult getInfo(@PathVariable("studentCourseId") Long studentCourseId)
    {
        return AjaxResult.success(scStudentCourseService.selectScStudentCourseByStudentCourseId(studentCourseId));
    }

    /**
     * 获取报名系统详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:scStudentCourse:query')")
    @GetMapping("/classList/{claId}")
    public AjaxResult getclaIdInfo(@PathVariable("claId") Long claId)
    {
        return AjaxResult.success(scStudentCourseService.selectScStudentCourseByclaId(claId));
    }

    /**
     * APP学生扣时信息
     */
    @PostMapping("/CourseSingleApp")
    public AjaxResult CourseSingleApp(@RequestBody ScStudentCourse scStudentCourse)
    {
        List<ScStudentCourse> scStudentCourses = scStudentCourseService.selectScStudentCourseList(scStudentCourse);
        return AjaxResult.success(scStudentCourses);
    }
    /**
     * 获取未点名信息
     */
//    @PreAuthorize("@ss.hasPermi('system:scStudentCourse:query')")
    @PostMapping("/mobileClassList")
    public AjaxResult getmobileClassList(@RequestBody ScClaTime scClaTime)
    {
        return AjaxResult.success(scStudentCourseService.getmobileClassList(scClaTime));
    }

    /**
     * 已经点名的信息
     */
//    @PreAuthorize("@ss.hasPermi('system:scStudentCourse:query')")
    @PostMapping("/mobileUpdateClassList")
    public AjaxResult getmobileUpdateClassList(@RequestBody ScClaTime scClaTime)
    {
        return AjaxResult.success(scStudentCourseService.getmobileUpdateClassList(scClaTime));
    }

    /**
     * 获取报名系统详细信息
     */
//    @PreAuthorize("@ss.hasPermi('system:scStudentCourse:query')")
    @GetMapping("/classList/claTimeAttend")
    public AjaxResult getclaIdUpdateInfo(ClaTimeAttend claTimeAttend)
    {
        return AjaxResult.success(scStudentCourseService.selectScStudentCourseByclaTimeAttend(claTimeAttend));
    }



    /**
     * 新增报名系统
     */
    @PreAuthorize("@ss.hasPermi('system:scStudentCourse:add')")
    @Log(title = "报名系统", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody List<ScCourseClaAttend> scCourseClaAttend ){
        return toAjax(scStudentCourseService.insertScStudentCourse(scCourseClaAttend));
    }

    /**
     * 修改报名系统
     */
    @PreAuthorize("@ss.hasPermi('system:scStudentCourse:edit')")
    @Log(title = "报名系统", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ScStudentCourse scStudentCourse)
    {
        return toAjax(scStudentCourseService.updateScStudentCourse(scStudentCourse));
    }

    /**
     * 删除报名系统
     */
    @PreAuthorize("@ss.hasPermi('system:scStudentCourse:remove')")
    @Log(title = "报名系统", businessType = BusinessType.DELETE)
	@DeleteMapping("/{studentCourseIds}")
    public AjaxResult remove(@PathVariable Long[] studentCourseIds)
    {
        return toAjax(scStudentCourseService.deleteScStudentCourseByStudentCourseIds(studentCourseIds));
    }
}
